home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9037 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  46 lines

  1. Path: holly.ACNS.ColoState.EDU!not-for-mail
  2. From: corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: How can I include IOSTREAM.H only once?
  5. Date: 27 Feb 1996 21:25:09 -0700
  6. Organization: Colorado State University, Fort Collins, CO  80523
  7. Message-ID: <4h0lf5$bli@holly.ACNS.ColoState.EDU>
  8. References: <4gre90$oei@service.polymtl.ca> <4guild$r2i@nnrp1.news.primenet.com>
  9. NNTP-Posting-Host: holly.acns.colostate.edu
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Brad Grossman (bjg@primenet.com) wrote:
  13. : Michael Gaudette <bluefox@info.polymtl.ca> wrote:
  14. : : I am presently engaged in what is usually called "the learning process", 
  15. : : and I've been programming simple programs with classes.  Because of this, 
  16. : : I have had to #include <iostream.h> in most of my "class.cpp" files AND 
  17. : : in my main program. This (added to conio.h and all the other standard 
  18. : : libraries) usually result in a simple program being 20000 lines long.
  19. : : Is there any way (using Borland v4.5) to make the compiler only link 
  20. : : those files ONCE?
  21.  
  22. : : Thanks in advance for any help I may receive
  23.  
  24. : I'm not all that experienced at C++ programming, but when looking through 
  25. : the container classes that come with C++, I see the solution to your 
  26. : problem.  Try this where you need IOSTREAM.H:
  27.  
  28. : #if !defined ( __IOSTREAM_H )
  29. : #include <iostream.h>
  30. : #endif
  31.  
  32. The #ifndef preprocessing is done by the standard includes anyway.  This is 
  33. reinventing the wheel.  Even though the program says it is 20000 lines,
  34. in actually, the appropriate code is only linked into the program once.
  35.  
  36. // ------------ BEGIN SIGNATURE ---------------
  37. #include <iostream.h>
  38. void main()
  39. {
  40.   cout<<"\aName:\tCorby S. Hudnall\n";
  41.   cout<<"School:\tColorado State University\n";
  42.   cout<<"EMail\tcorbyh@holly.colostate.edu\n";
  43.   cout<<"URL\thttp://holly.colostate.edu/~corbyh/\n";
  44. }
  45. // ------------- END SIGNATURE ----------------
  46.